<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
  </head>

  <body>
    <button id="btn1">获取值</button>
    <input id="inp1" type="text" value="文本框的值" placeholder="请输入值" />

    <hr />
    <input id="btn2" type="button" value="设置值" />

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script>
      // 获取值
      $('#btn1').click(function () {
        console.log('获取值', $('#inp1').val())
      })

      // 设置值
      $('#btn2').click(function () {
        $('#inp1').val('Hello World')
      })
    </script>
  </body>
</html>
